package com.seleniti.enpareja.controller.common.exception;

import org.ioc.commons.flowcontrol.exceptionparser.ErrorCodeException;

/**
 * PoZit exception
 */
public class EnParejaException extends ErrorCodeException {

	private static final long serialVersionUID = 1L;
	public static final String PREFIX = "ENPAREJAERROR";

	public enum ErrorCode {
		PERMISSION_DENIED, LOGGIN_REQUIRED, PASSWORD_ENCRYPTION_FAILURE, USER_ALREADY_HAS_A_COUPLE, USER_NOT_FOUND, NOTIFICATION_DEVICE_NOT_FOUND
		;

	}

	private ErrorCode errorCode;

	public EnParejaException(ErrorCode errorCode) {
		super(EnParejaException.PREFIX, errorCode);
		this.errorCode = errorCode;
	}

	public EnParejaException(ErrorCode errorCode, String detailedInfo) {
		super(EnParejaException.PREFIX, errorCode, detailedInfo);
		this.errorCode = errorCode;
	}

	public EnParejaException(ErrorCode errorCode, Throwable cause) {
		super(EnParejaException.PREFIX, errorCode, cause);
		this.errorCode = errorCode;
	}

	public EnParejaException(ErrorCode errorCode, String detailedInfo, Throwable cause) {
		super(EnParejaException.PREFIX, errorCode, detailedInfo, cause);
		this.errorCode = errorCode;
	}

	public ErrorCode getErrorCode() {
		return errorCode;
	}

	public static EnParejaException fromMessage(String message) {
		return fromMessage(EnParejaException.class, ErrorCode.class, PREFIX, message,
				new NewInstanceResolver<EnParejaException, ErrorCode>() {

					@Override
					public EnParejaException newInstance(ErrorCode errorCode, String exceptionMessage) {
						return new EnParejaException(errorCode, exceptionMessage);
					}

				});
	}

}
